package com.gpnu7_412.yanzhi.controller.user;

import com.gpnu7_412.yanzhi.entity.User;
import com.gpnu7_412.yanzhi.service.InterestService;
import com.gpnu7_412.yanzhi.util.Result;
import com.gpnu7_412.yanzhi.util.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author HJJ
 * @deprecated
 */
@CrossOrigin
@RestController
@RequestMapping("/user")
public class LikeAndBeLikeController {
    @Autowired
    private InterestService interestService;

    /**
     * 获取当前登录用户的关注列表
     * @return 响应对象
     */
    @GetMapping("/myLike")
    public Result selectMyLikeList() {
        Map<String, Object> map = ThreadLocalUtil.get();
        Integer userId = (Integer) map.get("userId");
        List<User> userLikeList = interestService.getUserLikeList(userId);
        HashMap<String, Object> request = new HashMap<>(2);
        request.put("totalCount", userLikeList.size());
        request.put("list", userLikeList);
        return new Result(request);
    }

    /**
     * 获取当前登录用户的粉丝列表
     * @return 响应对象
     */
    @GetMapping("/fans")
    public Result selectFansList() {
        Map<String, Object> map = ThreadLocalUtil.get();
        Integer userId = (Integer) map.get("userId");
        List<User> fansList = interestService.getFansList(userId);
        HashMap<String, Object> request = new HashMap<>(2);
        request.put("totalCount", fansList.size());
        request.put("list", fansList);
        return new Result(request);
    }
}
